<template>
	<view class="yun-content login">
		<view class="main">主体内容</view>
		<button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
			手机号一键登录
		</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		getPhoneNumber(e) { // 在bindgetphonenumber回调中获取code动态令牌
			loginFn().then(res => { // 微信登录&服务端获取openid
				console.log(res, '接口换取的openid')
				console.log('获取手机号的动态令牌:', e.detail.code) // 动态令牌
				getPhoneNumberFn(e.detail.code, res.openid).then(res2 => { // 服务端获取手机号
					if (res2.code == 0) {
						uni.setStorageSync('phoneNumber', res.content.phone_info.phoneNumber)
						uni.showToast({
							title: '登录成功'
						})
					}
				})
			})
		},
	}
</script>

<style scoped lang="scss">
	.login {
		width: 100vw;
		height: 80vh;
		display: flex;
		flex-direction: column;
		.main{
			flex: 1;
		}
	}
</style>